import request from "@/util/http";
import qs from "qs";

export default {
  gain(forms) {
    return request({
      method: "get",
      params: {
        _gp: "admin.coupon",
        _mt: "queryCouponByTitle",
        title: forms.distitle,
        type: forms.type,
        status: forms.statuss,
        pageNo: forms.pageNo,
        limit: forms.limit
      }
    });
  },
  //新增
  adduser(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.coupon",
        _mt: "addCoupon",
        title: form.title,
        type: form.type,
        description: form.description,
        limit: form.limit,
        discount: form.discount,
        min: form.min,
        status: form.status,
        total: form.total,
        categoryId: form.categoryId,
        days: form.days,
        gmtStart: form.gmtStart,
        gmtEnd: form.gmtEnd
      })
    });
  },
  //修改
  compile(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.coupon",
        _mt: "updateCoupon",
        id: form.id,
        title: form.title,
        type: form.type,
        description: form.description,
        limit: form.limit,
        discount: form.discount,
        min: form.min,
        status: form.status,
        surplus: form.surplus,
        total: form.total,
        categoryId: form.categoryId,
        days: form.days,
        gmtStart: form.gmtStart,
        gmtEnd: form.gmtEnd
      })
    });
  },
  //冻结
  state(id, status) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.coupon",
        _mt: "updateCouponStatus",
        id: id,
        status: status
      })
    });
  },
  //删除接口
  cancel(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin.coupon",
        _mt: "deleteCoupon",
        id: form.id
      })
    });
  },
  //获取一级SPU树
  spu() {
    return request({
      method: "get",
      params: {
        _gp: "admin.category",
        _mt: "categoryTree"
      }
    });
  },
   //获取二级SPU树
   sputwo() {
    return request({
      method: "get",
      params: {
        _gp: "admin.category",
        _mt: "categorySecondLevelTree"
      }
    });
  }
};
